﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PPIDesktopClient.Entities;
using System.Data;
using PPIDesktopClient.General;
using PPIProxy;
using VMind.Global;
using PPIMobileInterface;

namespace PPIDesktopClient.Logic
{
    public class LXMissionStructures_PoleTreatments
    {
        public static List<EXMissionStructures_PoleTreatment> SelectAllIdName(DataTable dt)
        {
            List<EXMissionStructures_PoleTreatment> _XMissionStructures_PoleTreatmentList = new List<EXMissionStructures_PoleTreatment>();
            EXMissionStructures_PoleTreatment _XMissionStructures_PoleTreatment;

            foreach (DataRow dr in dt.Rows)
            {
                _XMissionStructures_PoleTreatment = new EXMissionStructures_PoleTreatment(ConvertHelper.ToInt32(dr["XMissionStructures_PoleTreatmentId"]), dr["Name"].ToString());
                _XMissionStructures_PoleTreatmentList.Add(_XMissionStructures_PoleTreatment);
            }
            return _XMissionStructures_PoleTreatmentList;

        }
        public static List<EXMissionStructures_PoleTreatment> SelectAllIdName()
        {
            ConfigReader _Reader = ConfigReader.GetInstance();
            DataTable dt = WXMissionStructures_PoleTreatments.SelectAllIdName(_Reader.GetConnectionString()).Tables[0];
            return SelectAllIdName(dt);

        }
        public static void InsertTreatments(string connectionString)
        {

            StringBuilder _query = new StringBuilder();
            List<EXMissionStructures_PoleTreatment> _treatments = LXMissionStructures_PoleTreatments.SelectAllIdName();
            foreach (EXMissionStructures_PoleTreatment t in _treatments)
            {
                _query.AppendLine("insert into tb_Lookups (LookupValue,LookupText,LookupTypeFk) values (" + t.XMissionStructures_PoleTreatmentId + ",'" + t.Name + "','Treatments')");
            }
            Utils.InsertTreatments(connectionString, _query.ToString());
        }

    }

}
